﻿/// Copyright © 2013 Microsoft Corporation. 
/// This project is released under the Microsoft Public License (MS-PL)
///
namespace Azure.Performance
{
    using Microsoft.WindowsAzure.Storage;
    using Microsoft.WindowsAzure.Storage.Table;

    public class TestResultRepository
    {
        private readonly CloudTableClient tableClient;

        public TestResultRepository(CloudStorageAccount account)
        {
            tableClient = account.CreateCloudTableClient();
        }

        public void Add(TestResultEntity result, string tableName = "results")
        {
            var table = tableClient.GetTableReference(tableName);
            table.CreateIfNotExists();

            var insertOperation = TableOperation.Insert(result);

            table.Execute(insertOperation);
        }
    }
}
